#if UNITY_EDITOR

using AI.Graph;
using UnityEditor;
using AI.Graph.Editor;

[CustomEditor (typeof (CanSeeCondition))]
public class CanSeeConditionView : ConditionView {

    private bool showVisibleTargets;


    public override void OnInspectorGUI () {
        DrawDefaultNode ();

        EditorGUILayout.Space ();

        CanSeeCondition condition = node as CanSeeCondition;

        if (condition) {
            showVisibleTargets = EditorGUILayout.Foldout (showVisibleTargets, $"Visible Targets ({condition.visibleTargetsList.Count})");
            if (showVisibleTargets) {
                for (int i = 0; i < condition.visibleTargetsList.Count; i++) {
                    EditorGUILayout.LabelField (condition.visibleTargetsList[i].name);
                }
            }
        }
    }


    protected override void OnSceneGUISelected () {
        if (aiBehaviour) {
            CanSeeCondition condition = node as CanSeeCondition;

            if (aiBehaviour.TryGetExposedObject (condition.fieldOfViewParameter, out FieldOfView fov)) {
                FieldOfViewInspector.DrawFieldOfView (fov.transform, condition.viewRadius, condition.viewAngle, condition.visibleTargetsList);
            }
        }
    }

}
#endif